<?php

namespace app\admin\model;

use think\Model;

class PxMsg extends Model
{
    // 表名
    protected $table = 'px_msg';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [
        'type_text',
        'is_read_text'
    ];
    

    
    public function getTypeList()
    {
        return ['preson' => __('Preson'),'all' => __('All')];
    }     

    public function getIsReadList()
    {
        return ['1' => __('Is_read 1')];
    }     


    public function getTypeTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['type'];
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsReadTextAttr($value, $data)
    {        
        $value = $value ? $value : $data['is_read'];
        $list = $this->getIsReadList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
